const { mock } = require('mockjs')
var data = mock({
  'data|30': [
    {
      id: '@increment(1)',
      rkdh: /BM\d{4}/ + '@date("yyyy-MM-dd")',
      kfmc: '@name',
      zgdw: '@name',
      'wzqf|1': [
        "被装",
        "油料",
        "器材",
        "药材"
      ],
      'rkzt|1': [
        "状态1",
        "状态2",
        "状态3",
        "状态4"
      ],
      'rklx|1': [
        "类型1",
        "类型2",
        "类型3",
        "类型4"
      ],
      datatime: '@date("yyyy-MM-dd")'
    },
  ],
}).data
module.exports = [
  {
    url: '/jigoulb/query',
    type: 'post',
    response(config) {
      const { title, pageNo = 1, pageSize = 15 } = config.body
      let mockList = data.filter((item) => {
        if (title && item.indexOf(title) < 0) return false
        return true
      })
      const pageList = mockList.filter(
        (item, index) =>
          index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
      )
      return {
        code: 200,
        msg: 'success',
        totalCount: mockList.length,
        data: pageList,
      }
    },
  },
  {
    url: '/personalCenter/doEdit',
    type: 'post',
    response() {
      return {
        code: 200,
        msg: '模拟保存成功',
      }
    },
  },
  {
    url: '/jigou/delete',
    type: 'post',
    response() {
      return {
        code: 200,
        msg: '模拟删除成功',
      }
    },
  },
]
